package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PathVariable;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand>, SelectByIdListMapper<Brand,Long> {

    @Insert("insert into tb_category_brand values(#{cid},#{bid})")
    public void insertCategoryBrand(@Param("cid")Long cid,@Param("bid")Long bid);

    @Delete("delete from tb_category_brand where brand_id = #{bid}")
    public void deleteCategoryBrandByBid(@Param("bid")Long bid);

    @Select("select brand_id from tb_category_brand where category_id = #{cid}")
    public List<Long> selectBrandIdByCid(@Param("cid")Long cid);

    @Select("SELECT * FROM tb_brand WHERE id IN(SELECT brand_id FROM tb_category_brand WHERE category_id = #{cid})")
    public List<Brand> queryBrandsByCid(@Param("cid")Long cid);




}
